$(document).ready(function() {

	//(function dateIndicatorInitializer() {
		dateIndicator = $(".date-indicator");
		dateIndicatorObject={};
		function mouseLeaveHandler(event){
			console.log("Mouse leave");
			logEvent(event);
			if(event.pageY < dateIndicatorObject.pageY){
				dateIndicator.insertBefore(dateIndicator.prev());
			}else{
				dateIndicator.insertAfter(dateIndicator.next());
			}
			dateIndicatorObject.pageY = event.pageY;
		}
		dateIndicator.mousedown(function(event) {
			event.preventDefault();
			dateIndicatorObject.pageY = event.pageY;
			dateIndicator.bind("mouseleave", mouseLeaveHandler);
		});
		$(".list-group").mouseup(function(event) {
			dateIndicator.unbind("mouseleave");
		});

		function logEvent(event){
			console.log("clientX: " + event.clientX + ", clientY:"+ event.clientY + 
					", offsetX: " + event.offsetX + ", offsetY:"+ event.offsetY + 
					", screenX: " + event.screenX + ", screenY:"+ event.screenY + 
					", pageX: " + event.pageX + ", pageY:"+ event.pageY);
		}
	
	//})();
});